{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import IPython\n",
    "from IPython.html.widgets import interact\n",
    "%matplotlib inline\n",
    "from sklearn import datasets\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "digits = datasets.load_digits()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def browse_images(digits):\n",
    "    n = len(digits.images)\n",
    "    def view_image(i):\n",
    "        plt.imshow(digits.images[i], cmap=plt.cm.gray_r, interpolation='nearest')\n",
    "        plt.title('Training: %s' % digits.target[i])\n",
    "        plt.show()\n",
    "    interact(view_image, i=(0,n-1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPYAAAEKCAYAAAAhNageAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADyxJREFUeJzt3X+MXOV1xvHvYxtkDOluCQ0EcLCVhiqVqhpEraTgZt2S\niCCaQBUpoJJgGqWpVBLcVmkoUhNbVRLUVspWaiO1ibEdSkgUB1xIofwImOJGUBy8/LKJAmUjmxpw\nSkzKDys4nP4xd+mwXnvvztz7zu7h+UiWZ2fuzDmz9jPvnZl731cRgZnlMm/QDZhZ8xxss4QcbLOE\nHGyzhBxss4QcbLOEHOxkJN0s6SNNb2tzi/w99uBJegGY+Ic4GtgP/Lz6+Q8j4rqBNNYgSecDnwcW\nA7uAKyPiXwbbVV4O9iwj6UngYxFx5xS3LYiIAwNoqy+S3gI8CfxeRNwq6VzgW8ApEfHjwXaXk3fF\nZzFJI5J2S/pzSXuAdZKGJX1H0rOSnpN0k6STuu6zRdLHqsur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KdpcBeSeslPSDpK5IWtVivW6NTew8i2G+I79ckHQNsAi6vRu7WRMSrEbEMOBn4LUkj\nbdSRdB7wbERsp+xofWZEnEZnptw/lrSipToLgNOBL0fE6cCLwBUt1XpNG1N7DyLYTwGLu35eTGfU\nTkPSEcC3gX+OiM2l6la7jf8KnNFSid8EPiDpSToz1v62pK+1VOs1EbGn+nsvneWllrdUajewOyLu\nr37eRCfobTvk1N69GkSwtwHvkLSkeqX6MHDjAPpohSQB64AdETFaoN5xkoary0cB7wW2t1ErIq6M\niMURsZTOruOdEfHRNmpNkLRI0puqy0cD7wNa+YYjIp4Gdkk6tbrqbODRNmpNcsipvXs1k3nFGxER\nByRdBtxK54OedRGxs616kq4D3gO8WdIu4LMRsb6tesCZwMXAQ5ImAvYXEfFvLdV7K7CxWjBxHnBN\nRHy3pVqTlXhbdTxwQ+f1kgXAtRFxW4v1PglcWw06TwCXtlire2rvRj878CGlZgn5yDOzhBxss4Qc\nbLOEHGyzhBxss4QcbLOEHGyzhBxss4T+D2la0yErlhmyAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f088a601f50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "browse_images(digits)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Accordion',\n",
       " 'AccordionWidget',\n",
       " 'BoundedFloatText',\n",
       " 'BoundedFloatTextWidget',\n",
       " 'BoundedIntText',\n",
       " 'BoundedIntTextWidget',\n",
       " 'Box',\n",
       " 'Button',\n",
       " 'ButtonWidget',\n",
       " 'CallbackDispatcher',\n",
       " 'Checkbox',\n",
       " 'CheckboxWidget',\n",
       " 'ContainerWidget',\n",
       " 'DOMWidget',\n",
       " 'Dropdown',\n",
       " 'DropdownWidget',\n",
       " 'FlexBox',\n",
       " 'FloatProgress',\n",
       " 'FloatProgressWidget',\n",
       " 'FloatRangeSlider',\n",
       " 'FloatSlider',\n",
       " 'FloatSliderWidget',\n",
       " 'FloatText',\n",
       " 'FloatTextWidget',\n",
       " 'HBox',\n",
       " 'HTML',\n",
       " 'HTMLWidget',\n",
       " 'Image',\n",
       " 'ImageWidget',\n",
       " 'IntProgress',\n",
       " 'IntProgressWidget',\n",
       " 'IntRangeSlider',\n",
       " 'IntSlider',\n",
       " 'IntSliderWidget',\n",
       " 'IntText',\n",
       " 'IntTextWidget',\n",
       " 'Latex',\n",
       " 'LatexWidget',\n",
       " 'Output',\n",
       " 'RadioButtons',\n",
       " 'RadioButtonsWidget',\n",
       " 'Select',\n",
       " 'SelectMultiple',\n",
       " 'SelectWidget',\n",
       " 'Tab',\n",
       " 'TabWidget',\n",
       " 'Text',\n",
       " 'TextWidget',\n",
       " 'Textarea',\n",
       " 'TextareaWidget',\n",
       " 'ToggleButton',\n",
       " 'ToggleButtonWidget',\n",
       " 'ToggleButtons',\n",
       " 'ToggleButtonsWidget',\n",
       " 'VBox',\n",
       " 'Widget',\n",
       " '__builtins__',\n",
       " '__doc__',\n",
       " '__file__',\n",
       " '__name__',\n",
       " '__package__',\n",
       " '__path__',\n",
       " '__warningregistry__',\n",
       " 'fixed',\n",
       " 'interact',\n",
       " 'interact_manual',\n",
       " 'interaction',\n",
       " 'interactive',\n",
       " 'jsdlink',\n",
       " 'jslink',\n",
       " 'register',\n",
       " 'warn_explicit',\n",
       " 'widget',\n",
       " 'widget_bool',\n",
       " 'widget_box',\n",
       " 'widget_button',\n",
       " 'widget_float',\n",
       " 'widget_image',\n",
       " 'widget_int',\n",
       " 'widget_link',\n",
       " 'widget_output',\n",
       " 'widget_selection',\n",
       " 'widget_selectioncontainer',\n",
       " 'widget_string']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir(IPython.html.widgets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
